<template>
  <div class="main-h">
    <Menu @search="search" @expand="expand" />
    <div class="main_graph">
      <EGraph 
      ref="main_graph"
      :height="height" 
      :search_content="graph_content" 
      :main_node_num="main_node_num"
      :graph_event_handler="main_graph_event_handler"
    />
    </div>
    
    <div class="fileDraw">
      <slider ref="r_slider" :slider_processed_handler="slider_processed_handler"></slider>
    </div>
  </div>
</template>
<script>
import Menu from "@/components/main/Menu.vue";
import slider from "@/components/main/slider.vue";
import EGraph from "@/components/main/EGraph.vue";
export default {
  name: "Home",
  components: { Menu, EGraph, slider },
  data() {
    return {
      user_info: null,
      height:700,
      graph_content:"[-all-]",
      main_node_num:50
    };
  },
  beforeCreate() {
    let user_info = this.$store.getters.getuser_info;
    if (user_info != null) {
      this.user_info = user_info;
    } else {
      this.$notify.warning({title:"登陆消息:",message:"未登录！！"});
      this.$router.replace("/login");
    }
  },
  created(){
    this.main_node_num=this.$store.getters.getmain_node_num;
  },
  mounted(){
    // this.expand();
  },
  methods: {
    search(search_content) {
      if (search_content) {
        // console.log("----home", search_content);
        this.$router.push({
          name: "Search",
          params: { body: JSON.stringify(search_content) },
        });
      }
    },
    expand() {
      this.$refs.r_slider.show_self();
    },
    main_graph_event_handler(search_content,node_num,node_total_num){
       this.$store.commit("setmain_node_num", node_num);
    },
    slider_processed_handler(){
     this.$refs.main_graph.flush()
    }
  },
};
</script>

<style scoped>
.main-h {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.main_graph{
  width: 100vw;
  height: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}
</style>
